home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Cafe 3
/
Visual Cafe 3.ISO
/
Vcafe
/
Main.bin
/
WizardResourceBundle.java
< prev
next >
Wrap
Text File
|
1998-09-08
|
3KB
|
151 lines
package com.symantec.itools.frameworks.wizard;
import java.util.ResourceBundle;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
import java.util.MissingResourceException;
/**
* @author Symantec Internet Tools Division
* @version 1.0
* @since VCafe 3.0
*/
public class WizardResourceBundle extends ResourceBundle
{
/**
* @since VCafe 3.0
*/
ResourceBundle resourceBundle;
public WizardResourceBundle(String baseName, Locale locale)
{
try
{
resourceBundle = ResourceBundle.getBundle(baseName, locale);
}
catch (MissingResourceException mre)
{
resourceBundle = null;
System.err.println("Resource bundle " + baseName + " not found");
}
}
/**
* @param key TODO
* @since VCafe 3.0
*/
public String getResourceString(String key)
{
String str = null;
try
{
str = resourceBundle.getString(key);
}
catch (MissingResourceException mre)
{
//str = "<<unknown>>";
System.err.println("Resource key " + key + " not found");
}
return str;
}
/**
* @param key TODO
* @since VCafe 3.0
*/
public final Object handleGetObject(String key)
{
// lazily load the lookup hashtable.
if (lookup == null)
{
loadLookup();
}
return lookup.get(key); // this class ignores locales
}
/**
* @since VCafe 3.0
*/
public Enumeration getKeys()
{
// lazily load the lookup hashtable.
if (lookup == null)
{
loadLookup();
}
Enumeration result = null;
if (parent != null)
{
Hashtable temp = new Hashtable();
for (Enumeration parentKeys = parent.getKeys() ;
parentKeys.hasMoreElements() ; /* nothing */)
{
temp.put(parentKeys.nextElement(), this);
}
for (Enumeration thisKeys = lookup.keys();
thisKeys.hasMoreElements() ; /* nothing */)
{
temp.put(thisKeys.nextElement(), this);
}
result = temp.keys();
}
else
{
result = lookup.keys();
}
return result;
}
/**
* @since VCafe 3.0
*/
private void loadLookup() {
Object[][] contents = getContents();
if (contents == null)
{
lookup = new Hashtable();
}
else
{
int len = contents.length;
if (len > 0)
lookup = new Hashtable(len);
else
lookup = new Hashtable();
for (int i = 0; i < len; ++i)
{
lookup.put(contents[i][0],contents[i][1]);
}
}
}
/**
* @since VCafe 3.0
*/
private Hashtable lookup = null;
/**
* @since VCafe 3.0
*/
public Object[][] getContents()
{
return contents;
}
/**
* @since VCafe 3.0
*/
static final Object[][] contents = {};
}